package net.babypai;

import net.babypai.common.Constants;
import net.babypai.logic.BabyPaiBaseService;
import net.babypai.logic.IiiYaActivity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;



public class Helloiiya extends Activity implements IiiYaActivity {
    /** Called when the activity is first created. */
	public static final int CHECKLOGIN = 1;
	private boolean FirstBoot = true;
	private String uId;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.helloiiya);
        BabyPaiBaseService.addActivity(this,"Helloiiya");
        getUserInfo();
        new Handler().postDelayed(new Runnable(){
    		@Override
    		public void run(){
    			SharedPreferences load_FirstBoot = getSharedPreferences(
						"FirstPreferences", 0);
				FirstBoot = load_FirstBoot.getBoolean("FirstBoot", true);
//    			if (FirstBoot) {
//					JumpToActivity(Welcome.class);
//				} else {
//					if(!"".equals(uId)){
//						JumpToActivity(Home.class);
//					}else{
//						JumpToActivity(Unlogin_PicWall.class);
//					}
//				}
				
				if(!"0".equals(uId)){
					JumpToActivity(Home.class);
				}else{
					JumpToActivity(Unlogin_PicWall.class);
				}
				
    			Helloiiya.this.finish();
    		}
    	}, 1000);
    }
    
    private void JumpToActivity(Class<?> cls) {
		Intent intent = new Intent();
		intent.setClass(this, cls);
		startActivity(intent);
	}
    
    private void getUserInfo(){
		SharedPreferences userInfo = getSharedPreferences(Constants.ACCOUNTS, MODE_PRIVATE);
		uId = userInfo.getInt(Constants.USER_ID, 0) + "";
		System.out.println("uId--->" + uId);
	}
    
	@Override
	public void init(int i) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
		
	}
}